#include "beats.h"
#include "beatslistmodel.h"
#include "ecg.h"
#include "ecgsignal.h"
#include "ecgdetection.h"
#include <QDateTime>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>

int main(int argc, char* argv[])
{
    QGuiApplication app(argc, argv);

    EcgDetection ecgdetection;

    // return 1;
    QQmlApplicationEngine engine;
    const QUrl url(u"qrc:/HeartVoiceAiEcgSystem/qml/Main.qml"_qs);
    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreationFailed,
        &app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);

    Ecg::getInstance().load();

    // 将MyClass实例暴露给QML
    engine.rootContext()->setContextProperty("EcgsignalModel", &EcgSignal::getInstance());
    engine.rootContext()->setContextProperty("beatsModel", &Beats::getInstance());

    qmlRegisterType<BeatsListModel>("BeatsListModel", 1, 0, "BeatsListModel");
    qmlRegisterSingletonInstance("EcgModel", 1, 0, "EcgModel", &Ecg::getInstance());

    engine.load(url);

    return app.exec();
}
